package client.comm.baoding.adapter

import android.content.Context
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView
import client.comm.baoding.R
import client.comm.baoding.api.bean.UserCards
import client.comm.baoding.databinding.LayoutBankmanagerItemBinding
import client.comm.commlib.base.BaseAdapter
import client.comm.commlib.base.BindingViewHoder

class BankManagerAdapter(context: Context) : BaseAdapter<UserCards.Card>(context) {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        val holder = BindingViewHoder(
            DataBindingUtil.inflate<ViewDataBinding>(
                layoutInflater,
                R.layout.layout_bankmanager_item, parent, false
            )
        )
        return holder
    }


    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        val bindingViewHolder = holder as BindingViewHoder<ViewDataBinding>
        val layoutAddrmangerItemBinding = bindingViewHolder.binding as LayoutBankmanagerItemBinding
        val bean = getItem(position)
        layoutAddrmangerItemBinding.e = bean
        layoutAddrmangerItemBinding.event = this
    }

    var itemClick: ((e: UserCards.Card) -> Unit)? = null

    fun runItemClick(e: UserCards.Card) {
        itemClick?.let {
            it(e)
        }
    }

}